<?php
namespace Admin\Controller;
use Admin\Controller\CheckController;
use Admin\Controller\BankController;
use Admin\Controller\ExpressController;
class ArchivesController extends AdminController{
	//档案管理
	public $express_company = [1=>'顺丰快递','圆通快递','中通快递','申通快递','韵达快递'];//快递公司

    protected function _initialize() {
		parent::_initialize ();
	}

	public function index()
	{
		$this->display();
	}

//银行归档资料递交
	public function data_submit()
	{
		$info=new CheckController();
	    $list=$info->getCheck_status(26,'!=-1');
	    $this->assign('list',$list);
		$this->display();
   }

   //还款卡管理(档案岗)
	public function repay_index()
	{
		$card=new BankController();
		$list=$card->Bank_Repay(1);
		$this->assign('express_company',$this->express_company);
		$this->assign('list',$list);
		$this->display();
	}

	//寄出快递（还款卡）
	public function add_express()
	{
		   if($_POST['act']==1){
           $id=explode(',',$_POST['ids']);
           $tems  = 0;
           foreach ($id as $v) {
             if($v!=0){
             	   $user=$this->getInfo('*','bank_repay','id='.$v.' and status=1');
                  if($user){
	                   $data['user_id']=$user['user_id'];
	                   $data['user_name']=$user['user_name'];
	                   $data['admin_id']=session('adminInfo.id');
	                   $data['send_name']=$_POST['send_name'];
	                   $data['addressee']=$_POST['addressee'];
	                   $data['express_number']=$_POST['express_number'];
	                   $data['file']=$_POST['express_content'];
	                   $data['company_id']=$_POST['company_id'];
	                   $express=new ExpressController();
	                   $data['express_company']=$express->express_company($_POST['company_id']);
	                   $data['express_times']=strtotime($_POST['express_times']);
	                   $data['add_times']=time();
	                   $data['update_times']=time();
	                   $data['status']=7;
	                   $result=M('express')->add($data);
                 //还款卡寄出记录
                   $log=array('user_id'=>$user['user_id'],'admin_id'=>session('adminInfo.id'),'admin_name'=>session('adminInfo.name'),'type'=>session('adminInfo.group_name'),'status'=>102,'opinion'=>'还款卡已寄出(档案岗)','note'=>'还款卡已寄出(档案岗)','add_time'=>time(),'check_status'=>41,'express_id'=> $result,'send_name'=>$_POST['send_name'],'addressee'=>$_POST['addressee'],'user_name'=>$user['user_name'],'express_number'=>$_POST['express_number'],'file'=>$_POST['express_content'],'express_times'=>strtotime($_POST['express_times']));
                   M('check_log')->add($log);
                   $check_data=array('update_time'=>time(),'status'=>2);
                   M('bank_repay')->where('id='.$v)->save($check_data);
                 }else{
                    $this->error('该文件已寄出');
                 }
             }
                $tems++;

           }
            $this->success("批量执行成功");

       }
	}
}